﻿#region using statements

using System;

using Microsoft.Xna.Framework;

using NGen.Managers.GUI;

using Nuclex.UserInterface;
using Nuclex.UserInterface.Controls;

#endregion

namespace XNAGameDemo.GUI
{
	internal class GUIElementIntroState : GUIElement
	{
		private readonly LabelControl m_longText = new LabelControl();

		private readonly LabelControl m_timer2Text = new LabelControl();

		private readonly LabelControl m_timerText = new LabelControl();

		private readonly WindowWithOkButtonControl m_window = new WindowWithOkButtonControl();

		private double m_gameTime;

		protected override void _Initialize() {
			m_window.Bounds = new UniRectangle(new UniScalar(0.5f, -250.0f), new UniScalar(0.25f, 0.0f), 500, 500);
			m_window.OkButton.Pressed += _OkButtonClick;

			_Children.Add(m_window);

			m_longText.Bounds = new UniRectangle(new UniScalar(0.05f, 0.0f), new UniScalar(0.1f, 0.0f), new UniScalar(0.1f, 0.0f), new UniScalar(0.2f, 0.0f));
			m_longText.Text = "This is the Game Introduction state.\n" + "The code in this demo teaches you how to use this engine.\n" + "It also shows you how to display variables within the windows.\n" + "The state select window will be open throughout this entire\n" + "demo to allow you to easily navigate through the game states\n" + "You have multiple options available to change te current\n" + "state. You can click the next or prev buttons, click the\n" + "state name directly, or use the f1 through f7 keys.";
			m_window.Children.Add(m_longText);
			m_window.Children.Add(m_timerText);
			m_window.Children.Add(m_timer2Text);
		}

		protected override void Update(GameTime p_gameTime) {
			m_gameTime += p_gameTime.ElapsedGameTime.TotalSeconds;
			m_timerText.Text = "Seconds Elapsed in this state: " + Math.Round(m_gameTime, 2);
			m_timerText.Bounds = new UniRectangle(new UniScalar(0.5f, -125.0f), new UniScalar(0.65f, 0.0f), 0, 0);

			m_timer2Text.Text = "Milliseconds since last frame " + Math.Round(p_gameTime.ElapsedGameTime.TotalMilliseconds, 2);
			m_timer2Text.Bounds = new UniRectangle(new UniScalar(0.5f, -125.0f), new UniScalar(0.75f, 0.0f), 0, 0);
		}

		protected override void _Cleanup() {}

		protected virtual void _OkButtonClick(object p_sender, EventArgs p_e) {
			_Children.Remove(m_window);
		}
	}
}